home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / YICN23.ZIP / SOURCE / STARS.CPP < prev    next >
C/C++ Source or Header  |  1993-03-06  |  2KB  |  73 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <alloc.h>
  5. #include "xlib.h"
  6. #include "xrect.h"
  7. #include "icon.h"
  8. #include "animicon.h"
  9. #include "yakFont.h"
  10. #include "yakMouse.h"
  11. #include "yakPal.h"
  12.  
  13. extern yakMouse mouse;
  14.  
  15. class star
  16. {
  17. public:
  18.   int x, y, xIncrement, yIncrement, size;
  19.   void initialize(void) {x = 100 + random(100); y = 60 + random(60); size = 5;};
  20.   void advance(void);
  21.   star(void) {initialize();};
  22. };
  23.  
  24. void star::advance(void)
  25. {
  26.   xIncrement = (x - 150)/5;
  27.   yIncrement = (y-100)/5;
  28.   x+=xIncrement;
  29.   y+=yIncrement;
  30.   size++;
  31.   if ((x < 0) || (x+size > 320)) initialize();
  32.   if ((y < 0) || (y+size > 200)) initialize();
  33. };
  34. void main(void)
  35. {
  36.   randomize();
  37.   yakLib myYakLib("draw");
  38.   icon starIcon, shipIcon;
  39.   icon::setZoomTable(64);
  40.   x_set_mode(2,360);
  41.   x_set_doublebuffer(200);
  42.   x_text_init();
  43.   mouse.init();
  44.   yakPalette myYakPalette("standard.ypl");
  45.   myYakPalette.put();
  46.   starIcon.load("star.yak", icon::normal, &myYakLib);
  47.   shipIcon.load("awayship.yak", icon::normal, &myYakLib);
  48.   int x, y, exit = 0;
  49.   int scale=200;
  50.   x = 50;
  51.   star stars[10];
  52.   while ((exit != 'Q') && (scale > 0))
  53.   {
  54.     x_rect_fill(0,0,320,200,HiddenPageOffs,0);
  55.     for (int starCounter = 0; starCounter < 10; ++starCounter)
  56.     {
  57.       stars[starCounter].advance();
  58.       starIcon.showZoomed(stars[starCounter].x, stars[starCounter].y, HiddenPageOffs, stars[starCounter].size);
  59.     }
  60.     scale-=4;
  61.     x += 2;
  62.     if (scale > 1)
  63.       shipIcon.showZoomed(x, 20, HiddenPageOffs, scale);
  64.  
  65.     x_page_flip(0,0);
  66.   }
  67.   for (int counter = 0; counter < 25; ++counter)
  68.   {
  69.     myYakPalette.fade(-5);
  70.     myYakPalette.put();
  71.   }
  72.   x_text_mode();
  73. }